package com.shop.shard.controller.assembler.order;

import com.shop.shard.controller.command.order.OrderItemCreateCommand;
import com.shop.shard.controller.command.order.OrderItemUpdateCommand;
import com.shop.shard.entity.order.OrderItem;

import java.util.Date;

/**
 * @Description: 代码生成器自动生成
 * @author:
 * @Createed Date: 2019-8-16 10:06:57
 * @ModificationHistory: Who  When  What
 * ---------     -------------   --------------------------------------
 **/
public class OrderItemAssembler{
    public static OrderItem toOrderItem(OrderItemCreateCommand command){
        OrderItem entity = new OrderItem();
        /** 订单id*/
        entity.setOrderId(command.getOrderId());
        /** 商品id*/
        entity.setProductId(command.getProductId());
        /** 单价*/
        entity.setItemPrice(command.getItemPrice());
        /** 数量*/
        entity.setTotalNum(command.getTotalNum());
        /** 订单总额*/
        entity.setTotalPrice(command.getTotalPrice());
        /** 下单时间*/
        entity.setOrderTime(command.getOrderTime());
        /** 用户id*/
        entity.setUserId(command.getUserId());
        /** 逻辑删除符*/
        Date currentDate = new Date();
        entity.setCreateDate(currentDate);
        entity.setUpdateDate(currentDate);
        return entity;
    }

    public static OrderItem toOrderItem(OrderItemUpdateCommand command){
        OrderItem entity = new OrderItem();
        /** 主键*/
        entity.setOrderItemId(command.getOrderItemId());
        /** 订单id*/
        entity.setOrderId(command.getOrderId());
        /** 商品id*/
        entity.setProductId(command.getProductId());
        /** 单价*/
        entity.setItemPrice(command.getItemPrice());
        /** 数量*/
        entity.setTotalNum(command.getTotalNum());
        /** 订单总额*/
        entity.setTotalPrice(command.getTotalPrice());
        /** 下单时间*/
        entity.setOrderTime(command.getOrderTime());
        /** 用户id*/
        entity.setUserId(command.getUserId());
        /** 逻辑删除符*/
        Date currentDate = new Date();
        entity.setUpdateDate(currentDate);
        return entity;
    }
}